package api.rowan.dubboservice.impl;

import api.rowan.dubboservice.mapper.UserMapper;
import api.rowan.pojo.Query;
import api.rowan.pojo.User;
import api.rowan.service.UserService;

import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.util.StringUtils;

@DubboService
@Component
public class UserServiceImpl implements UserService {

    @Autowired
    UserMapper userMapper;

    @Override
    public User getUser(Query query) {
        User user = userMapper.getDefaultUser();
        if(StringUtils.hasLength(user.getName())) user.setName(query.getName());
        if(query.getId()!=0) user.setAge(query.getId());
        return user;
    }
}
